package com.boyunvision.common;


import com.imgdb.rawTcp.Api;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ApiConfig {
  @Value("${api.dbipaddr}")
  private String dbipaddr;
  
  @Value("${api.dbport}")
  private Integer dbport;

  @Value("${api.conntimeout}")
  private Integer conntimeout;

  @Value("${api.recvtimeout}")
  private Integer recvtimeout;
  
  private Api api;
  
  @PostConstruct
  private synchronized void initApi() {
    this.api = new Api(this.dbipaddr, this.dbport.intValue(),conntimeout,recvtimeout);
  }
  
  public Api getApi() {
    return this.api;
  }
}
